package com.lib76.DBInfo.model.po.mysql;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Embeddable;

import org.apache.commons.lang.StringUtils;

/**
 * MYSQL数据列信息主键
 * @author 张浩
 * @version 0.0.1
 */
@Embeddable
public class TableColumnKey implements Serializable{

	private static final long serialVersionUID = 1L;
	
	@Column(name="TABLE_SCHEMA")
	private String tableSchema;
	@Column(name="TABLE_NAME")
	private String tableName;
	@Column(name="COLUMN_NAME")
	private String columnName;
	public String getTableSchema() {
		return tableSchema;
	}
	public void setTableSchema(String tableSchema) {
		this.tableSchema = tableSchema;
	}
	public String getTableName() {
		return tableName;
	}
	public void setTableName(String tableName) {
		this.tableName = tableName;
	}
	public String getColumnName() {
		return columnName;
	}
	public void setColumnName(String columnName) {
		this.columnName = columnName;
	}
	
	@Override
	public int hashCode() {
		return super.hashCode();
	}
	
	@Override
	public boolean equals(Object obj) {
		if(obj != null && TableColumnKey.class.isInstance(obj)){
			TableColumnKey key = (TableColumnKey)obj;
			if(StringUtils.isNotBlank(key.getTableSchema()) 
					&& StringUtils.isNotBlank(key.getTableName())
					&& StringUtils.isNotBlank(key.getColumnName())
					&& key.getTableSchema().equals(this.tableSchema)
					&& key.getTableName().equals(this.tableName)
					&& key.getColumnName().equals(this.columnName)){
				return true;
			}
		}
		return super.equals(obj);
	}
}
